package duoqiao;

import java.io.File;
import java.io.FileFilter;

public class A2 {
    //lambda
    public static void main(String[] args) {
        FileFilter filter = new FileFilter() {//实现的接口只有一个抽象方法
            @Override
            public boolean accept(File filename) {
                return filename.getName().contains("s");
            }
        };
        File dir = new File(".");//获取根目录下的
        File[] subs = dir.listFiles(filter);
        System.out.println(subs.length);
        for (int i = 0;i< subs.length;i++){
            System.out.println(subs[i].getName());
        }
        FileFilter filter1 =(File pathname)-> {
                return false;//去掉new出来的接口和方法的定义
        };


















//        FileFilter filter =(File pathname) ->{
//                return pathname.getName().contains("o");
//        };
//        File dir = new File(".");
//        //如果是个目录才要展示出来
//        if (dir.isDirectory()) {
//            File[] subs = dir.listFiles(filter);
//            for (int i = 0;i< subs.length;i++){
//                System.out.println(subs[i].getName());
//            }
//            System.out.println("子项有"+subs.length);
//        }
    }
}
